#include <mpi.h>
#include <stdio.h>


void fortran_allreduce_(const double* sendbuf, double* recvbuf, const int* count, const MPI_Fint* f_comm);

int main(int argc, char** argv) {
    MPI_Init(&argc, &argv);

    MPI_Fint f_comm = MPI_Comm_c2f(MPI_COMM_WORLD);

    int rank;
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);

    const int count = 2;
    double sendbuf[2] = {1.0 + rank, 10.0 + rank};
    double recvbuf[2] = {0};

    fortran_allreduce_(sendbuf, recvbuf, &count, &f_comm);

    printf("Rank %d: Results = [%.1f, %.1f]\n", rank, recvbuf[0], recvbuf[1]);

    MPI_Finalize();
    return 0;
}